<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>日期</title>
</head>
<body>
    <script>
        let now = new Date();
        console.log(now);

        let d = new Date("2022-08-20 13:40:50");
        console.log(d);

        //月份[0,11];
        let dd = new Date(2022,4,1,13,12,11);
        console.log(dd);

        console.log(now.getFullYear());
        console.log(now.getMonth()+1);
        console.log(now.getDate());
        console.log(now.getDay());//周日是0
        console.log(now.getHours());
        console.log(now.getMinutes());
        console.log(now.getSeconds());
        console.log(now.getTime());

        //利用毫秒数来构建
        let dt = new Date(now.getTime()+232323232);
        console.log(dt)
    </script>
</body>
</html>